home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / t3_1 / risc_src.lha / risc_sources / sys / frame.t < prev    next >
Text File  |  1989-06-30  |  4KB  |  100 lines

  1. (herald frame (env tsys))
  2.  
  3. ;;; Copyright (c) 1985 Yale University
  4. ;;;     Authors: N Adams, R Kelsey, D Kranz, J Philbin, J Rees.
  5. ;;; This material was developed by the T Project at the Yale University Computer 
  6. ;;; Science Department.  Permission to copy this software, to redistribute it, 
  7. ;;; and to use it for any purpose is granted, subject to the following restric-
  8. ;;; tions and understandings.
  9. ;;; 1. Any copy made of this software must include this copyright notice in full.
  10. ;;; 2. Users of this software agree to make their best efforts (a) to return
  11. ;;;    to the T Project at Yale any improvements or extensions that they make,
  12. ;;;    so that these may be included in future releases; and (b) to inform
  13. ;;;    the T Project of noteworthy uses of this software.
  14. ;;; 3. All materials developed as a consequence of the use of this software
  15. ;;;    shall duly acknowledge such use, in accordance with the usual standards
  16. ;;;    of acknowledging credit in academic research.
  17. ;;; 4. Yale has made no warrantee or representation that the operation of
  18. ;;;    this software will be error-free, and Yale is under no obligation to
  19. ;;;    provide any services, by way of maintenance, update, or otherwise.
  20. ;;; 5. In conjunction with products arising from the use of this material,
  21. ;;;    there shall be no use of the name of the Yale University nor of any
  22. ;;;    adaptation thereof in any advertising, promotional, or sales literature
  23. ;;;    without prior written consent from Yale in each case.
  24. ;;;
  25.  
  26. ;;;; stuff for hacking stack frames
  27.  
  28. ;;; Frame-previous returns frame in stack to which the given stack
  29. ;;; frame will return.  If there is no such "superior", return null.
  30.        
  31. (define (closure? obj)
  32.   (and (extend? obj)
  33.        (template? (extend-header obj))))
  34.  
  35. (define (frame? obj)
  36.   (and (extend? obj)
  37.        (template? (frame-header obj))))
  38.  
  39.                            
  40. (define handle-stack-base
  41.   (object nil
  42.     ((frame-previous frame) (ignore frame) nil)
  43.     ((get-environment frame)   (ignore frame) nil)
  44.     ((frame-print-synopsis frame port) (ignore frame port) nil)
  45.     ((print-type-string self) "Stack-base")))
  46.  
  47. (define handle-magic-frame                       
  48.   (object nil
  49.     ((get-environment frame)   (ignore frame) nil)
  50.     ((frame-print-synopsis frame port) (ignore frame port) nil)
  51.     ((print-type-string self) "Dynamic-state-transition")))
  52.  
  53. (define (frame-any pred frame)
  54.   (cond ((frame? frame)
  55.      (let ((limit (frame-size frame)))
  56.        (iterate loop2 ((i 0))
  57.          (cond ((fx>= i limit) nil)
  58.            ((pred (extend-pointer-elt frame i)))
  59.            (else (loop2 (fx+ i 1)))))))
  60.         (else nil)))
  61.          
  62. (define (frame-size thing)
  63.   (cond ((frame? thing)
  64.          (template-pointer-slots (frame-header thing)))
  65.         (else 0)))
  66.                                          
  67. (define-operation (frame-previous frame)
  68.   (let ((frame (enforce frame? frame)))
  69.     (let ((tem (frame-header frame)))
  70.       (make-pointer frame (template-pointer-slots tem)))))
  71.  
  72.  
  73. (define (closure-size-info closure)
  74.   (let ((tem (extend-header closure)))
  75.     (return (template-pointer-slots tem) 0)))
  76.     
  77. (define (template-definer tem)
  78.   (let ((offset (template-definer-vcell-offset tem)))
  79.     (if offset
  80.         (vcell-id (extend-pointer-elt (template-unit tem) offset))
  81.         nil)))
  82.  
  83. (define (template-unit tem)
  84.   (let ((thing (template-enclosing-object tem)))
  85.     (xcond ((not (bytev? thing)) thing)
  86.            ((weak-table-entry code-unit-table thing)))))
  87.     
  88.  
  89. (define (template-definer-vcell-offset template)
  90.   (let ((template (if (fixnum-equal? (template-nargs template) 0)
  91.                       (extend-elt template 0)
  92.                       template)))
  93.     (let ((offset (fixnum-ashr (mref-16-u template
  94.                       (fx+ -2 template/annotation)) 3)))
  95.       (if (fx= offset 0) 
  96.           nil
  97.           (fx- offset 1)))))
  98.             
  99.  
  100.